import {AfterViewInit, Component, Input, OnInit} from '@angular/core';
import Swiper from 'swiper';

@Component({
  selector: 'app-swiper-instance',
  templateUrl: './swiper-instance.component.html',
  styleUrls: ['./swiper-instance.component.css']
})
export class SwiperInstanceComponent implements OnInit, AfterViewInit {
  swiper: Swiper;
  @Input() slides: any[];
  constructor() { }

  ngOnInit() {
    console.log(this.slides);
  }

  ngAfterViewInit(): void {
    this.swiper = new Swiper('.swiper-container', {
      direction: 'vertical',
      speed: 300,
      loop: true,
      autoplay: true,
      // 如果需要分页器
      // pagination: {
      //   el: '.swiper-pagination',
      // },
      // 如果需要前进后退按钮
      // navigation: {
      //   nextEl: '.swiper-button-next',
      //   prevEl: '.swiper-button-prev',
      // },
      // 如果需要滚动条
      // scrollbar: {
      //   el: '.swiper-scrollbar',
      // },
    });
  }
}
